<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>本专业意见列表</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="Expires" CONTENT="0">
    <meta http-equiv="Cache-Control" content="no-siteapp,no-transform,no-store, no-cache, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/weadmin.css">
    <script type="text/javascript" src="/lib/layui/layui.js" charset="utf-8"></script>
    <link rel="stylesheet" href="/static/css/buildUnit/common.css">

</head>
<body>
<div class="content">
    <div class="layui-tab" lay-filter="demo">
        <div class="layui-tab-content tabel-fold">
            <table id="dataList" lay-filter="dataList"></table>
            <script type="text/html" id="barDemo">
                {{#  if(d.ifCanEdit === true){ }}<!--是否是自己添加的意见-->
                {{#  if(d.ifThisTimes === true){ }}<!--是否是本轮意见-->
                <a class="layui-btn layui-btn-xs" lay-event="change">修改</a>
                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</a>
                <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="confirmChange">确认修改</a>
                {{#  } }}
                {{#  if(d.ifThisTimes === false){ }}<!--是否是本轮意见-->
                <a class="layui-btn layui-btn-xs" lay-event="change">修改</a>
                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</a>
                {{#  } }}
                {{#  } }}

            </script>
        </div>
    </div>
</div>
<script src="/static/js/main.js"></script>
<script>
    //Demo
    layui.use([
        'jquery',
        'configureCom',
        'configure',
        'element',
        'suggest',
        'element',
        'sessionFun',
        'bluebird',
        'table',
        'matchDict'
    ], function () {
        var $ = layui.jquery;
        var configureCom = layui.configureCom;
        var configure = layui.configure;
        var suggest = layui.suggest;
        var sessionFun = layui.sessionFun;
        var element = layui.element;
        var table = layui.table;
        var matchDict = layui.matchDict;
        var listData = sessionFun.get(configure.SESSION_PROJECT_WAIT_LIST_DATA);
        var drawingData = sessionFun.get(configure.SESSION_DRAWING_DATA);
        //意见列表请求参数
        var tableData = {
            decId: listData.decId   //部门类型
        };
        //意见请求url
        var url = configure.EXPERT_SPECITY_SUGGEST_HTTP;
        var cols = [[ //表头
            {
                field: 'drawingNum', title: '图号', templet: function (d) {
                    return '<p>' + d.drawingNum + '</p><p class="child-td">轮数：' + (d.checkTimes || '1') + '</p>';
                }
            },
            {
                field: 'articleType', title: '条文性质', templet: function (d) {
                    if (d.articleType == 1) {
                        return '<p>' + matchDict.name(d.articleType, configure.ARTICLE_TYPE) + '</p><p>强条类型:' + matchDict.name(d.qiangtiaoType, configure.QIANGTIAO_CODE) + '</p>'
                    } else {
                        return '<p>' + matchDict.name(d.articleType, configure.ARTICLE_TYPE) + '</p>'

                    }
                }
            },
            {
                field: 'adviseTxt', title: '意见'
            },
            {
                field: 'expertName', title: '专家'
            },
            {title: '操作', width: 200, align: 'center', toolbar: '#barDemo'}
        ]];
        //渲染表格
        configureCom.tableRender(configure.EXPERT_SPECITY_SUGGEST_HTTP, {
            decId: listData.decId,
            specialtyId: drawingData.specialtyId
        }, cols);
        //一些事件监听
        element.on('tab(demo)', function (data) {
            tableData.adviseOrgType = $(data.elem['context']).attr('lay-id');
            configureCom.tableRender(configure.EXPERT_SPECITY_SUGGEST_HTTP, tableData, cols);
        });

        table.on('tool(dataList)', function (obj) {
            //存入意见对象
            var data = obj.data;
            sessionFun.set(configure.SESSION_SUGGEST_DATA, data);
            //修改意见
            if (obj.event === 'change') {
                top.layer.open({
                    type: 2,
                    title: '修改意见',
                    area: configureCom.Psize1,
                    content: configure.EXPERT_ADD_SUGGEST_HTML + '?type=change',
                    btnAlign: 'c',
                    btn: ['保存'],
                    yes: function (index, layero) {
                        var iframeWin = top.window.frames['layui-layer-iframe' + index]; //得到iframe页的窗口对
                        iframeWin.getData().then(function (res) {
                            suggest.add(res.result).then(function () {
                                top.layer.msg('修改成功');
                                configureCom.tableReload(true);
                                top.layer.close(index);
                            });
                        });
                    }
                });
            } else if (obj.event === 'delete') {
                //删除意见
                top.layer.confirm('确认删除当前意见吗?', function (index) {
                    top.layer.close(index);
                    suggest.deleteSuggest(data).then(function (res) {
                        top.layer.msg('删除成功！');
                        var randomId = obj.data.randomId || '';//pdf圈阅意见Id
                        if (randomId) {
                            window.parWin.deleteYj(randomId);
                        }
                        configureCom.tableReload(true);
                    });
                });
            } else if (obj.event === 'confirmChange') {
                //确认修改前几轮意见
                top.layer.confirm(configure.TITLE_CONFIRMATION, function (index) {
                    suggest.confirmChange().then(function (res) {
                        top.layer.msg(configure.MSG_SAVE);
                        configureCom.tableReload(false, tableData, configure.EXPERT_SPECITY_SUGGEST_HTTP);
                    });
                    top.layer.close(index);
                });
            }
        });
    });
</script>
</body>
</html>